//
//  BaseTableViewController.swift
//  Weibo19
//
//  Created by 城 on 15/11/8.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate{   //设置登录标示
    var userLogin  = UserAccountViewModel().userLogin
    //设置为可选类型,,可空
      var visitorLoginView: VisitorLoginView?
    override func loadView() {
 //三目运算,,为真UItableview 为假 UIView
        userLogin ? super.loadView() : loadvieDid()
    }
    
    private func loadvieDid(){
        
      
        //赋值View
     visitorLoginView = VisitorLoginView()
    visitorLoginView!.visitorLoginVDelegate = self
       //设置nav的登录按钮
     self.navigationItem.leftBarButtonItem = UIBarButtonItem (title: "登陆", style: .Plain, target: self, action: "visitorWillLogin")
        //设置nav的注册按钮
    self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
       
        
        view = visitorLoginView
    }
    //代理方法也是点击方法
    func visitorWillLogin(){
    let oauthView = OAuthViewController()
        
   let nav =  UINavigationController(rootViewController: oauthView)
        
      presentViewController(nav, animated: true, completion: nil)
    }
    
    func visitorWillRegister(){
    
      print("comm on")
    }
    override func viewDidLoad() {
        super.viewDidLoad()

       
    }

   
}
